#ifndef _CMDDEAL_H
#define _CMDDEAL_H


#include"Polynomial.h"
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
using namespace std;


class CmdDeal {
public:
    vector<Polynomial> Po;
    struct Mypolynomial {
        Polynomial Poly;
        int pos;
        Mypolynomial() {}
        Mypolynomial(Polynomial POLY, int po):Poly(POLY),pos(po) { }
        Mypolynomial(const Mypolynomial& B):Poly(B.Poly),pos(B.pos){}
    };
    struct Myoperator {
        char op;
        int pos;
        double a, b;
        Myoperator() {}
        Myoperator(char c, int po) :op(c), pos(po) { a = b = -100; }
        Myoperator(char c, double x, double y, int po) :op(c), a(x), b(y), pos(po) { ; }
    };
    stack<Mypolynomial> stackpoly;
    stack<Myoperator> stackoper;
    string tempn;//临时多项式名称，用于拆出多项式的名字
    int dot;//判断小数点是否已经出现
    double num;
    int dou;
    int de;
    CmdDeal() { Po.clear(); dot = 0; num = 0; dou = 0; de = 0; }
    ~CmdDeal() { Po.clear(); }
    bool AddPo(int mysize, double* M, string pname);
    bool ScanPo(string name);
    int findpo(string name);
    int calculate();
    int analy(string ex);
    int getPriority(char c);
    int getPrioritycal(char c);
    int cal_or_not(char c);
    void clean() { 
        num = 0; dou = 0; de = 0; dot = 0; 
        while (!stackpoly.empty())stackpoly.pop();
        while (!stackoper.empty())stackoper.pop();
    }
};






#endif _CMDDEAL_H